package cqrtplm.listener;

import com.hustcad.plm.pdm.workflow.annotion.CustomListener;
import com.hustcad.plm.pdm.workflow.model.constant.ProcessConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;

@Slf4j
@CustomListener(category = "润通", description = "快速生成物料码")
public class QuicklyGenerateMaterialCodeListener implements ExecutionListener {
    @Override
    public void notify(DelegateExecution execution) {
        long start = System.currentTimeMillis();
        String workFlowContainerId = execution.getProcessInstanceBusinessKey();
        log.info("----------润通----快速生成物料码------开始------workFlowContainerId:{}----->>>",
                 workFlowContainerId);
        if (StringUtils.isBlank(workFlowContainerId)) {
            workFlowContainerId = execution.getVariable(ProcessConstant.WORK_FLOW_CONTAINER_ID).toString();
        }
        String finalWorkFlowContainerId = workFlowContainerId;
//        RTPartService rtPartService = SpringUtil.getBean(RTPartService.class);
//        rtPartService.quicklyGenerateMaterialCode(new BigInteger(finalWorkFlowContainerId));

        log.info("----------润通----快速生成物料码,耗时：{}---->>>", System.currentTimeMillis() - start);
    }
}
